package com.zymic.callrecord;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class CallRecord01 extends Activity {
    private Button beginrecordservice;
    private Button end;
    
    private Button btnAddLis;
    private Button btnRemoveLis;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //
        beginrecordservice=(Button)findViewById(R.id.startrecordservice);
        beginrecordservice.setOnClickListener(new BeginRecord());
        
        end=(Button)findViewById(R.id.endrecordservice);
        end.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                Intent serviceIntent=new Intent(getApplicationContext(),CallRecordService.class);
                getApplicationContext().stopService(serviceIntent);
            }
        });
        
        
        btnAddLis=(Button)findViewById(R.id.send_add);
        btnAddLis.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                sendAddBro();
            }
            
        });
        
        btnRemoveLis=(Button)findViewById(R.id.send_remove);
        btnRemoveLis.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                removeLisBro();
            }
            
        });
            
        
        
    }
    //
    private class BeginRecord implements OnClickListener{

		@Override
		public void onClick(View v) {
			Intent serviceIntent=new Intent(getApplicationContext(),CallRecordService.class);
			getApplicationContext().startService(serviceIntent);
			
		}
    	
    }
    
    
    private void sendAddBro()
    {
        Intent intent=new Intent(CallRecordService.ADD_Lis);
        sendBroadcast(intent);
    }
    
    private void removeLisBro()
    {
        Intent intent=new Intent(CallRecordService.REMOVE_Lis);
        sendBroadcast(intent);
    }
}